/*
 * Launcher.cpp
 *
 *  Created on: 29.03.2011
 *      Author: niea
 */

#include "Launcher.hpp"

using namespace efs;

Launcher::Launcher(Settings const& settings)
	: m_tcp_listener(settings.my_net_settings.tcp_port)
	, m_udp_listener(settings, &m_client_list)
	, m_udp_pinger(settings)
	, m_tcp_messenger(&m_client_list)
	, m_file_server(settings.folder, settings.my_net_settings.file_port)
	, m_folder_manager(settings.folder, settings.folder_monitor_period, settings)
{
	m_folder_manager.setExternalRes(&m_file_client, &m_tcp_messenger);
	m_tcp_listener.setSubscriber(&m_folder_manager);
}

Launcher::~Launcher()
{

}

void efs::Launcher::start()
{
	pantheios::log_INFORMATIONAL("[Launcher]: starting all threads");
	m_file_server.start();
	m_folder_manager.start();
	m_udp_listener.start();
	m_tcp_listener.startListening();
	m_udp_pinger.start();
}

void efs::Launcher::stop()
{
	pantheios::log_INFORMATIONAL("[Launcher]: stopping all threads");
	m_udp_pinger.stop();
	m_tcp_listener.stopListening();
	m_udp_listener.stop();
	m_folder_manager.stop();
	m_file_server.stop();
}





